package com.xzzz.expand.gateway.dr;

import com.xzzz.common.base.exception.XzException500;

/**
 * 断言枚举
 *
 * @author : xzzz
 */
public enum PredicateEnum {
    /**
     * 断言类型
     */
    After,
    Before,
    Between,
    Cookie,
    Header,
    Host,
    Method,
    Path,
    Query,
    RemoteAddr
    ;

    PredicateEnum(){
    }

    /**
     * 根据code返回信息
     * @param key key
     * @return value
     */
    public static String byName(String key) {
        for (PredicateEnum item : PredicateEnum.values()) {
            if (item.name().equals(key)) {
                return item.name();
            }
        }
        throw new XzException500("断言名称不存在");
    }
}
